import d from "highlight.js/lib/languages/d"
import { listToMap } from "../../utils/map"
import request from "../../utils/request"

// 查询身份列表
export function listIdentity(query) {
  return request({
    url: '/configManager/identity/list',
    method: 'get',
    params: query
  })
}

// 查询身份详细
export function getIdentity(id) {
  return request({
    url: '/configManager/identity/' + id,
    method: 'get'
  })
}

// 新增身份
export function addIdentity(data) {
  return request({
    url: '/configManager/identity',
    method: 'post',
    data: data
  })
}

// 修改身份
export function updateIdentity(data) {
  return request({
    url: '/configManager/identity',
    method: 'put',
    data: data
  })
}

// 删除身份
export function delIdentity(id) {
  return request({
    url: '/configManager/identity/' + id,
    method: 'delete'
  })
}

/**
 * @param {import("vue").Component} component
 * @returns 
 */
export function listIdentitys(component) {
    return request.post('/configManager/identity/listIdentitys/').then(res => {

        let data =  res.data;
        component.identitys = data;

        component.identityMap = listToMap(data)

        localStorage.setItem("identitys", JSON.stringify( component.identityMap));

        return res;
    })
}
